using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TankWars.Weapons
{
    class Missile : Shot
    {
        private const int N_MISSILE_POWER = 15;
        public const int N_TIME_BETWEEN_FIRING = 1200;
        public const int N_MAX_AMMO = 10;
        public const WeaponManager.WeaponCategory SHOT_CATEGORY = WeaponManager.WeaponCategory.Ammo;

        private float fSpeed = 190.0f;

        public Missile(Tank firingTank, Texture2D missileSprite) 
            : base(missileSprite)
        {
            base.FiringTank = firingTank;

            base.nPower = N_MISSILE_POWER;

            //Set the position and rotation of the missle to the tank's turret.
            base.fRotation = firingTank.Turret.fRotation;
            base.vPosition = firingTank.Turret.EndOfTurret;
            this.highGround = base.FiringTank.highGround;   //Set bullet to same level as tank.
            base.vPosition.X += (base.SpriteWidth / 2) * (float)Math.Cos(base.fRotation);
            base.vPosition.Y += (base.SpriteWidth / 2) * (float)Math.Sin(base.fRotation);

            //Set the speed of the missle relative to its rotation.
            base.vSpeed.X = (float)(this.fSpeed*Math.Cos(base.fRotation));
            base.vSpeed.Y = (float)(this.fSpeed*Math.Sin(base.fRotation));
            //vSpeed += base.FiringTank.vSpeed;   //Add the tanks velocity to the bullet.
        }

        public Missile(Tank firingTank, Texture2D missileSprite, string strSpriteName, string strFrameXMLFile)
            : base(strSpriteName, missileSprite, strFrameXMLFile)
        {
            base.FiringTank = firingTank;

            base.nPower = N_MISSILE_POWER;

            base.strExplodeAnimationLabel = "MissileExplosion";

            //Set the position and rotation of the missle to the tank's turret.
            base.fRotation = firingTank.Turret.fRotation;
            base.vPosition = firingTank.Turret.EndOfTurret;
            this.highGround = base.FiringTank.highGround;   //Set bullet to same level as tank.
            base.vPosition.X += (base.SpriteWidth / 2) * (float)Math.Cos(base.fRotation);
            base.vPosition.Y += (base.SpriteWidth / 2) * (float)Math.Sin(base.fRotation);

            //Set the speed of the missle relative to its rotation.
            base.vSpeed.X = (float)(this.fSpeed * Math.Cos(base.fRotation));
            base.vSpeed.Y = (float)(this.fSpeed * Math.Sin(base.fRotation));
            //vSpeed += base.FiringTank.vSpeed;   //Add the tanks velocity to the bullet.
        }
    }
}
